/*
 * 通关作业1:
  var str = “fjskfjsl fjkdsjfkls fjklsfjlsd127.0.0.1fjksldfjafjio jfk192.168.1.101sljfs fsdjfkldsfjsklfsklffjoijfoiaf  asfjs fed jfjf jf sdjfsi jfi jafis function  dd ( ) { }afjsdiajf iosa function abc(){} jfisjad fjsaiofjaoissf addedfds”
  写两个正则表达式，一个是匹配 127.110.60.1 和 192.168.1.101 。
  另一个是正则表达式，要匹配 javascript 函数。
*/

const log = console.log;

let str = "fjskfjsl fjkdsjfkls fjklsfjlsd127.110.60.1fjksldfjafjio jfk192.168.1.101sljfs fsdjfkldsfjsklfsklffjoijfoiaf  asfjs fed jfjf jf sdjfsi jfi jafis function  dd ( ) { }afjsdiajf iosa function abc(x,y){ console.log('dddd') } jfisjad fjsaiofjaoissf addedfds";

//匹配 127.110.60.1 和 192.168.1.101
let rg1 = /\d{3}.\d{3}.\d+.\d+/g;
let rg2 = /\d{3}.\d{3}.\d{1,}.\d{1,}/g;

let result1 = rg1.exec(str);
log(result1[0]);

log("---------------------");
let result2 = rg1.exec(str);
log(result2[0]);
log("---------------------");

// 匹配 javascript 函数
let rg3 = /function\s+[a-z]*\s*\([\sa-z,]*\)\s*{[^}]*}/gi;
let result3 = rg3.exec(str);
log(result3[0]);

log("---------------------");
let result4 = rg3.exec(str);
log(result4[0]);
